package com.gyf.backoffice.service.impl;

import com.gyf.backoffice.mapper.ItemsMapper;
import com.gyf.backoffice.model.Items;
import com.gyf.backoffice.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemaServiceImpl implements ItemsService {

    @Autowired
    private ItemsMapper itemsMapper;

    @Override
    public List<Items> findAllItems() {
        return itemsMapper.findAllItems();
    }

    public void saveOrupdate(Items items){
        if(items.getId() == null){
            itemsMapper.insert(items);
        }else{
            itemsMapper.updateByPrimaryKey(items);
        }
    }

    @Override
    public void delete(Integer id) {
        itemsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Items items) {
       return itemsMapper.updateByPrimaryKeySelective(items);
    }

    @Override
    public Items findItemsOne(Integer id) {
        return itemsMapper.selectByPrimaryKey(id);
    }


}
